/**
 * 桥架模式:针对两个抽象化的角色，进行桥接。比如，女医生，男老师，等等
 * 用例：红色的包，红色是实现类，包是抽象类。包的实现类有多种。
 */
public class BridgePattern {
    public static void main(String[] args) {

        HawaiPhone hawaiPhone = new HawaiPhone();
        RedPhoneShell redPhoneShell = new RedPhoneShell();
        redPhoneShell.setType(hawaiPhone);
        System.out.println(redPhoneShell.getColor());


        XiaomiPhone xiaomiPhone = new XiaomiPhone();
        BlackPhoneShell blackPhoneShell = new BlackPhoneShell();
        blackPhoneShell.setType(xiaomiPhone);
        System.out.println(blackPhoneShell.getColor());

    }

}
//手机
 class Phone {
    String name;
    public String getName(){
        return this.name;
    }
}
class HawaiPhone extends Phone{
    @Override
    public String getName(){
        return  "huawei";
    }
}
class XiaomiPhone extends Phone{
    @Override
    public String getName(){
        return  "xiaomi";
    }
}
//手机壳
abstract class PhoneShell {
    Phone phone;
    String color;
    public void setType(Phone phone){
        this.phone = phone;
    }
    abstract String getColor();
}

//红色的手机壳
class RedPhoneShell extends PhoneShell{
    public RedPhoneShell(){
    }
    @Override
    public String getColor(){
        return "red" +"\t"+ phone.getName() +"\t"+ "shell";
    }

}
//黑色的手机壳
class BlackPhoneShell extends PhoneShell{
    @Override
    public String getColor(){
        return "black" +"\t"+ phone.getName() +"\t"+ "shell";
    }
}